package com.wushi.lenovo.asia5b.app_ui.pay.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.mvp.utils.StringUtils;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.credit.bean.ThirdTopupType;
import com.wushi.lenovo.asia5b.app_model.credit.bean.TopupInfoBean;
import com.wushi.lenovo.asia5b.app_model.other.WebUrlType;
import com.wushi.lenovo.asia5b.app_ui.credit.fragment.CardFragment;
import com.wushi.lenovo.asia5b.app_ui.pay.activity.PayActivity;
import com.wushi.lenovo.asia5b.app_utils.eye.EyeUtils;

import butterknife.BindView;

/**
 * Created by zhangyuncai on 2020/3/4.
 * 订单支付visa付款
 */
public class PayCardFragment extends CardFragment {
    @BindView(R.id.tv_pay_orderprice)
    TextView tv_pay_orderprice;
    private PayActivity payActivity;
    private TopupInfoBean topupInfoBean;

    @Override
    protected int getLayout() {
        return R.layout.fragment_paycard;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        thirdTopupType = ThirdTopupType.thirdtopup_from_orderpayment_by_creditcard;
        payActivity = (PayActivity) mActivity;
        topupInfoBean = payActivity.topupInfoBean;
    }

    @Override
    protected void setView() {
        tv_pay_orderprice.setText(String.format("%s %s", getString(R.string.rm), StringUtils.formatNum2(topupInfoBean.getTotalAmount() + "")));
        super.setView();
        et_card_amount.setText(topupInfoBean.getDiffAmount() + "");

        et_card_amount.setEnabled(false);
        ll_card_price_vessel.setVisibility(View.GONE);
        bt_card_submit.setText(R.string.orderpayment_proceedpayment);
        tv_card_notice.setVisibility(View.VISIBLE);
        //超链接
        EyeUtils.setLinkText(mActivity, getString(R.string.shopcar_pi_notice), getString(R.string.shopcar_pi_notice_key),
                tv_card_notice, WebUrlType.shopcar_pi);
    }

    @Override
    protected float getAmount() {
        return StringUtils.parseFloat(topupInfoBean.getTotalAmount());
    }

    @Override
    protected int getCheckout_log_id() {
        return topupInfoBean.getCheckout_log_id();
    }

    @Override
    public TopupInfoBean getTopupInfoBean() {
        return topupInfoBean;
    }
}
